# 基础镜像
FROM ubuntu:latest

# build参数
ARG user=dbeaver
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai

# 安装依赖
RUN apt-get update \
    && apt-get install -y \
    libxcb-keysyms1-dev \
    libxcb-image0-dev \
    libxcb-shm0-dev \
    libxcb-icccm4-dev \
    libxcb-sync0-dev \
    libxcb-xfixes0-dev \
    libxcb-shape0-dev \
    libxcb-randr0-dev \
    libxcb-render-util0-dev \
    libfontconfig1-dev \
    libfreetype6-dev \
    libx11-dev \
    libxext-dev \
    libxfixes-dev \
    libxi-dev \
    libxrender-dev \
    libxcb1-dev \
    libx11-xcb-dev \
    libxcb-glx0-dev \
    x11vnc \
    xauth \
    mesa-common-dev \
    libglu1-mesa-dev \
    libxkbcommon-dev \
    libxcb-xkb-dev \
    libxslt1-dev \
    libgstreamer-plugins-base1.0-dev \
    libxkbcommon-x11-0 \
    sudo \
    tar \
    gzip \
    aria2 \
    libgtk3.0 \
    maven \
    mysql-client

# 添加用户：赋予sudo权限，指定密码
RUN useradd --create-home --no-log-init --shell /bin/bash ${user} \
    && adduser ${user} sudo \
    && echo "${user}:123456" | chpasswd

# 复制字体
COPY ./fonts/* /usr/share/fonts

# 下载并安装dbeaver
RUN aria2c -c "https://dbeaver.io/files/dbeaver-ce-latest-linux.gtk.x86_64.tar.gz" -o /tmp/dbeaver/dbeaver-ce-23.1.4-linux.gtk.x86_64.tar.gz
RUN tar xvzf /tmp/dbeaver/dbeaver-ce-23.1.4-linux.gtk.x86_64.tar.gz  -C /usr/lib/
RUN ln -s /usr/lib/dbeaver/dbeaver /usr/bin/
RUN rm -rf /tmp/dbeaver/*

# 指定工作目录
WORKDIR /home/${user}

# 指定登录用户
USER ${user}

# 指定docker run时执行的程序
ENTRYPOINT dbeaver
